<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>06-计算用户全名</title>
</head>
<body>
<div id="app">
    姓：<input placeholder="firstName" v-model="firstName"/></br>
    名：<input placeholder="lastName" v-model="lastName"/></br>
    全名1：<input placeholder="fullName1" v-model="fullName1"/></br>
    全名2：<input placeholder="fullName2" v-model="fullName2"/></br>
</div>

<script src="vue.js"></script>
<script>
    new Vue({
        el: '#app',
        data: {
            firstName: 'Zeng',
            lastName: 'RenJie',
        },
        computed: {
            fullName1(){
                console.log('fullName1被调用')
                return this.firstName+' '+this.lastName
            },
            fullName2: {
                get(){
                    console.log('fullName2 get方法被调用')
                    return this.firstName+' '+this.lastName
                },
                set(values){
                    console.log('fullName2 set方法被调用')
                    const names = values.split(' ')
                    this.firstName = names[0]
                    this.lastName = names[1]
                }
            }
        }
    })
</script>

</body>
</html>